package sysytmRepo

import (
	"gorm.io/gorm"
	"ruoyi/domain/entity/response"
	"ruoyi/domain/repository"
)

type SysRoleMenuRepo struct {
	db *gorm.DB
}

func SysRoleMenuRepository(db *gorm.DB) *SysRoleMenuRepo {
	return &SysRoleMenuRepo{db}
}

var _ repository.SysRoleMenuRepository = &SysRoleMenuRepo{}

func (r *SysRoleMenuRepo) DeleteRoleMenu(roleIds string) {
	sql := "delete from sys_role_menu where role_id in ( " + roleIds + " )"
	err := r.db.Exec(sql).Error
	if err != nil {
		panic(response.ReturnFailMsg(err.Error()))
	}

}

func (r *SysRoleMenuRepo) DeleteRoleMenuByRoleId(roleId string) {
	sql := "delete from sys_role_menu where role_id = " + roleId
	err := r.db.Exec(sql).Error
	if err != nil {
		panic(response.ReturnFailMsg(err.Error()))
	}
}
